LCR 035. 最小时间差
为保证权益,题目请参考 LCR 035. 最小时间差(From LeetCode).
解决方案1
Python
python
from typing import List
class Solution:
def findMinDifference(self, timePoints: List[str]) -> int:
def get_minute(t: str) -> int:
return int(t[0:2]) * 60 + int(t[3:5])
timePoints.sort()
mins = list(map(get_minute, timePoints))
ans = 999999999
for i in range(len(timePoints) - 1):
ans = min(ans, abs(mins[i] - mins[i + 1]))
ans = min(ans, abs(mins[0] + 1440 - mins[len(timePoints) - 1]))
return ans
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19